from sqlalchemy import Column, Integer, String, DateTime, Text, Boolean
from sqlalchemy.sql import func
from app.core.database import Base

class ImageRecord(Base):
    """图片记录表"""
    __tablename__ = "images"
    
    id = Column(Integer, primary_key=True, index=True)
    entity_id = Column(String(255), nullable=False, index=True, comment="图片实体ID")
    group_id = Column(String(255), nullable=False, index=True, comment="图库ID")
    pic_name = Column(String(255), nullable=False, comment="图片名称")
    original_filename = Column(String(255), comment="原始文件名")
    
    # COS相关字段
    cos_url = Column(Text, comment="COS访问URL")
    cos_key = Column(String(500), comment="COS对象键")
    
    # 文件信息
    file_size = Column(Integer, comment="文件大小(字节)")
    file_type = Column(String(50), comment="文件类型")
    width = Column(Integer, comment="图片宽度")
    height = Column(Integer, comment="图片高度")
    
    # TIIA相关字段
    tencent_tags = Column(Text, comment="腾讯云识别标签(JSON)")
    custom_content = Column(Text, comment="自定义内容")
    upload_status = Column(String(50), default="success", comment="上传状态")
    tencent_response = Column(Text, comment="腾讯云响应(JSON)")
    
    # 系统字段
    user_id = Column(Integer, comment="用户ID")
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
    updated_at = Column(DateTime(timezone=True), onupdate=func.now(), comment="更新时间")
    deleted_at = Column(DateTime(timezone=True), comment="删除时间")